init()
{
	game["menu_quickcommands"] = "quickcommands";
	game["menu_quickstatements"] = "quickstatements";
	game["menu_quickresponses"] = "quickresponses";
	precacheMenu(game["menu_quickcommands"]);
	precacheMenu(game["menu_quickstatements"]);
	precacheMenu(game["menu_quickresponses"]);

	game["menu_shiftquickcommands"] = "shiftquickcommands";
	game["menu_shiftquickstatements"] = "shiftquickstatements";
	game["menu_shiftquickresponses"] = "shiftquickresponses";
	precacheMenu(game["menu_shiftquickcommands"]);
	precacheMenu(game["menu_shiftquickstatements"]);
	precacheMenu(game["menu_shiftquickresponses"]);

	precacheHeadIcon("talkingicon");
	precacheString( &"QUICKMESSAGE_FOLLOW_ME" );
	precacheString( &"QUICKMESSAGE_MOVE_IN" );
	precacheString( &"QUICKMESSAGE_FALL_BACK" );
	precacheString( &"QUICKMESSAGE_SUPPRESSING_FIRE" );
	precacheString( &"QUICKMESSAGE_ATTACK_LEFT_FLANK" );
	precacheString( &"QUICKMESSAGE_ATTACK_RIGHT_FLANK" );
	precacheString( &"QUICKMESSAGE_HOLD_THIS_POSITION" );
	precacheString( &"QUICKMESSAGE_REGROUP" );
	precacheString( &"QUICKMESSAGE_ENEMY_SPOTTED" );
	precacheString( &"QUICKMESSAGE_ENEMY_DOWN" );
	precacheString( &"QUICKMESSAGE_IM_IN_POSITION" );
	precacheString( &"QUICKMESSAGE_AREA_SECURE" );
	precacheString( &"QUICKMESSAGE_GRENADE" );
	precacheString( &"QUICKMESSAGE_SNIPER" );
	precacheString( &"QUICKMESSAGE_NEED_REINFORCEMENTS" );
	precacheString( &"QUICKMESSAGE_HOLD_YOUR_FIRE" );
	precacheString( &"QUICKMESSAGE_YES_SIR" );
	precacheString( &"QUICKMESSAGE_NO_SIR" );
	precacheString( &"QUICKMESSAGE_IM_ON_MY_WAY" );
	precacheString( &"QUICKMESSAGE_SORRY" );
	precacheString( &"QUICKMESSAGE_GREAT_SHOT" );
	precacheString( &"QUICKMESSAGE_TOOK_LONG_ENOUGH" );
	precacheString( &"QUICKMESSAGE_ARE_YOU_CRAZY" );
	
	// Precache [SHIFT] spearhead sounds
	precacheString( &"SHIFT_ATTACK" );
	precacheString( &"SHIFT_COVER_ME" );
	precacheString( &"SHIFT_I_COVER_YOU" );
	precacheString( &"SHIFT_COVERING_FIRE" );
	precacheString( &"SHIFT_GRENADE" );
	precacheString( &"SHIFT_FOLLOW_ME" );
	precacheString( &"SHIFT_OPEN_FIRE" );
	precacheString( &"SHIFT_TAKE_POINT" );
	precacheString( &"SHIFT_MOVE_SIGNAL" );
	precacheString( &"SHIFT_ALL_YOU_GOT" );
	precacheString( &"SHIFT_TARGET_PRACTICE" );
	precacheString( &"SHIFT_COME_PREPARED" );
	precacheString( &"SHIFT_COWARDS" );
	precacheString( &"SHIFT_RUN_YELLOW" );
	precacheString( &"SHIFT_HIDING" );
	precacheString( &"SHIFT_WANTS_MORE" );
	precacheString( &"SHIFT_TOO_EASY" );
	precacheString( &"SHIFT_MESS_BEST" );
	precacheString( &"SHIFT_YES_SIR" );
	precacheString( &"SHIFT_NO_SIR" );
	precacheString( &"SHIFT_THANKS" );
	precacheString( &"SHIFT_I_OWE_YOU" );
	precacheString( &"SHIFT_GOOD_JOB" );
	precacheString( &"SHIFT_DONE_IT" );
	precacheString( &"SHIFT_TAKING_FIRE" );
	precacheString( &"SHIFT_ENEMY_SPOTTED" );
	precacheString( &"SHIFT_WOOHOO" );	
	
		
}
quickcommands(response)
{
	self endon ( "disconnect" );
	
	if(!isdefined(self.pers["team"]) || self.pers["team"] == "spectator" || isdefined(self.spamdelay))
		return;
	self.spamdelay = true;
	
	switch(response)		
	{
		case "1":
			soundalias = "mp_cmd_followme";
			saytext = &"QUICKMESSAGE_FOLLOW_ME";
			
			break;
		case "2":
			soundalias = "mp_cmd_movein";
			saytext = &"QUICKMESSAGE_MOVE_IN";
			
			break;
		case "3":
			soundalias = "mp_cmd_fallback";
			saytext = &"QUICKMESSAGE_FALL_BACK";
			
			break;
		case "4":
			soundalias = "mp_cmd_suppressfire";
			saytext = &"QUICKMESSAGE_SUPPRESSING_FIRE";
			
			break;
		case "5":
			soundalias = "mp_cmd_attackleftflank";
			saytext = &"QUICKMESSAGE_ATTACK_LEFT_FLANK";
			
			break;
		case "6":
			soundalias = "mp_cmd_attackrightflank";
			saytext = &"QUICKMESSAGE_ATTACK_RIGHT_FLANK";
			
			break;
		case "7":
			soundalias = "mp_cmd_holdposition";
			saytext = &"QUICKMESSAGE_HOLD_THIS_POSITION";
			
			break;
		default:
			assert(response == "8");
			soundalias = "mp_cmd_regroup";
			saytext = &"QUICKMESSAGE_REGROUP";
			
			break;
	}
	self saveHeadIcon();
	self doQuickMessage(soundalias, saytext);
	wait 2;
	self.spamdelay = undefined;
	self restoreHeadIcon();	
}
quickstatements(response)
{
	if(!isdefined(self.pers["team"]) || self.pers["team"] == "spectator" || isdefined(self.spamdelay))
		return;
	self.spamdelay = true;
	
	switch(response)		
	{
		case "1":
			soundalias = "mp_stm_enemyspotted";
			saytext = &"QUICKMESSAGE_ENEMY_SPOTTED";
			
			break;
		case "2":
			soundalias = "mp_stm_enemydown";
			saytext = &"QUICKMESSAGE_ENEMY_DOWN";
			
			break;
		case "3":
			soundalias = "mp_stm_iminposition";
			saytext = &"QUICKMESSAGE_IM_IN_POSITION";
			
			break;
		case "4":
			soundalias = "mp_stm_areasecure";
			saytext = &"QUICKMESSAGE_AREA_SECURE";
			
			break;
		case "5":
			soundalias = "mp_stm_grenade";
			saytext = &"QUICKMESSAGE_GRENADE";
			
			break;
		case "6":
			soundalias = "mp_stm_sniper";
			saytext = &"QUICKMESSAGE_SNIPER";
			
			break;
		case "7":
			soundalias = "mp_stm_needreinforcements";
			saytext = &"QUICKMESSAGE_NEED_REINFORCEMENTS";
			
			break;
		default:
			assert(response == "8");
			soundalias = "mp_stm_holdyourfire";
			saytext = &"QUICKMESSAGE_HOLD_YOUR_FIRE";
			
			break;
	}
	self saveHeadIcon();
	self doQuickMessage(soundalias, saytext);
	wait 2;
	self.spamdelay = undefined;
	self restoreHeadIcon();
}
quickresponses(response)
{
	if(!isdefined(self.pers["team"]) || self.pers["team"] == "spectator" || isdefined(self.spamdelay))
		return;
	self.spamdelay = true;
	switch(response)		
	{
		case "1":
			soundalias = "mp_rsp_yessir";
			saytext = &"QUICKMESSAGE_YES_SIR";
			
			break;
		case "2":
			soundalias = "mp_rsp_nosir";
			saytext = &"QUICKMESSAGE_NO_SIR";
			
			break;
		case "3":
			soundalias = "mp_rsp_onmyway";
			saytext = &"QUICKMESSAGE_IM_ON_MY_WAY";
			
			break;
		case "4":
			soundalias = "mp_rsp_sorry";
			saytext = &"QUICKMESSAGE_SORRY";
			
			break;
		case "5":
			soundalias = "mp_rsp_greatshot";
			saytext = &"QUICKMESSAGE_GREAT_SHOT";
			
			break;
		case "6":
			soundalias = "mp_rsp_tooklongenough";
			saytext = &"QUICKMESSAGE_TOOK_LONG_ENOUGH";
			
			break;
		default:
			assert(response == "7");
			soundalias = "mp_rsp_areyoucrazy";
			saytext = &"QUICKMESSAGE_ARE_YOU_CRAZY";
			
			break;
	}
	self saveHeadIcon();
	self doQuickMessage(soundalias, saytext);
	wait 2;
	self.spamdelay = undefined;
	self restoreHeadIcon();
}
shiftquickcommands(response)
{
	if(!isdefined(self.pers["team"]) || self.pers["team"] == "spectator" || isdefined(self.spamdelay))
		return;
	self.spamdelay = true;
	switch(response)		
	{
		case "1":
			soundalias = "attack";
			saytext = &"SHIFT_ATTACK";
			break;

		case "2":
			soundalias = "coverme";
			saytext = &"SHIFT_COVER_ME";
			break;

		case "3":
			soundalias = "icoveru";
			saytext = &"SHIFT_I_COVER_YOU";
			break;

		case "4":
			soundalias = "squadcoverfire";
			saytext = &"SHIFT_COVERING_FIRE";
			break;

		case "5":
			soundalias = "grenadetakecover";
			saytext = &"SHIFT_GRENADE";
			break;

		case "6":
			soundalias = "followme";
			saytext = &"SHIFT_FOLLOW_ME";
			break;

		case "7":
			soundalias = "openfire";
			saytext = &"SHIFT_OPEN_FIRE";
			break;

		case "8":
			soundalias = "youtakepoint";
			saytext = &"SHIFT_TAKE_POINT";
			break;

		default:
			assert(response == "9");
			soundalias = "moveonsig";
			saytext = &"SHIFT_MOVE_SIGNAL";
			break;
	}
	self saveHeadIcon();
	self doQuickMessage(soundalias, saytext);
	wait 2;
	self.spamdelay = undefined;
	self restoreHeadIcon();	
}
shiftquickstatements(response)
{
	if(!isdefined(self.pers["team"]) || self.pers["team"] == "spectator" || isdefined(self.spamdelay))
		return;
	self.spamdelay = true;
	switch(response)		
	{
		case "1":
			soundalias = "allyougot";
			saytext = &"SHIFT_ALL_YOU_GOT";
			break;

		case "2":
			soundalias = "backaftertargetpractice";
			saytext = &"SHIFT_TARGET_PRACTICE";
			break;

		case "3":
			soundalias = "comepreparednext";
			saytext = &"SHIFT_COME_PREPARED";
			break;

		case "4":
			soundalias = "cowards";
			saytext = &"SHIFT_COWARDS";
			break;

		case "5":
			soundalias = "runyellowbelly";
			saytext = &"SHIFT_RUN_YELLOW";
			break;

		case "6":
			soundalias = "wherehiding";
			saytext = &"SHIFT_HIDING";
			break;

		case "7":
			soundalias = "whowantsmore";
			saytext = &"SHIFT_WANTS_MORE";
			break;

		case "8":
			soundalias = "tooeasy";
			saytext = &"SHIFT_TOO_EASY";
			break;

		default:
			assert(response == "9");
			soundalias = "messbest";
			saytext = &"SHIFT_MESS_BEST";
			break;
	}
	self saveHeadIcon();
	self doQuickMessageForAll(soundalias, saytext);
	wait 2;
	self.spamdelay = undefined;
	self restoreHeadIcon();
}
shiftquickresponses(response)
{
	if(!isdefined(self.pers["team"]) || self.pers["team"] == "spectator" || isdefined(self.spamdelay))
		return;
	self.spamdelay = true;
	switch(response)		
	{
		case "1":
			soundalias = "yessir";
			saytext = &"SHIFT_YES_SIR";
			break;

		case "2":
			soundalias = "nosir";
			saytext = &"SHIFT_NO_SIR";
			break;

		case "3":
			soundalias = "thanks";
			saytext = &"SHIFT_THANKS";
			break;

		case "4":
			soundalias = "ioweyouone";
			saytext = &"SHIFT_I_OWE_YOU";
			break;

		case "5":
			soundalias = "goodjob";
			saytext = &"SHIFT_GOOD_JOB";
			break;

		case "6":
			soundalias = "doneit";
			saytext = &"SHIFT_DONE_IT";
			break;

		case "7":
			soundalias = "fireneedhelp";
			saytext = &"SHIFT_TAKING_FIRE";
			break;

		case "8":
			soundalias = "enemyspot";
			saytext = &"SHIFT_ENEMY_SPOTTED";
			break;

		default:
			assert(response == "9");
			soundalias = "wooohoo";
			saytext = &"SHIFT_WOOHOO";
			break;
	}
	self saveHeadIcon();
	self doQuickMessage(soundalias, saytext);
	wait 2;
	self.spamdelay = undefined;
	self restoreHeadIcon();
}
doQuickMessage( soundalias, saytext )
{
	if(self.sessionstate != "playing")
		return;
	if ( self.pers["team"] == "allies" )
	{
		if ( game["allies"] == "russian" )
			prefix = "RU_";
		else
			prefix = "US_";
	}
	else
	{
		if ( game["axis"] == "nva" )
			prefix = "VC_";
		else
			prefix = "GE_";
	}
	if(isdefined(level.QuickMessageToAll) && level.QuickMessageToAll)
	{
		self.headiconteam = "none";
		self.headicon = "talkingicon";
		self playSound( prefix+soundalias );
		self sayAll(saytext);
	}
	else
	{
		if(self.sessionteam == "allies")
			self.headiconteam = "allies";
		else if(self.sessionteam == "axis")
			self.headiconteam = "axis";
		
		self.headicon = "talkingicon";
		self playSound( prefix+soundalias );
		self sayTeam( saytext );
		self pingPlayer();
	}
}
doQuickMessageForAll( soundalias, saytext )
{
	if(self.sessionstate != "playing")
		return;
	if ( self.pers["team"] == "allies" )
	{
		if ( game["allies"] == "russian" )
			prefix = "RU_";
		else
			prefix = "US_";
	}
	else
	{
		if ( game["axis"] == "nva" )
			prefix = "VC_";
		else
			prefix = "GE_";
	}

	self.headiconteam = "none";
	self.headicon = "talkingicon";

	self playSound( prefix+soundalias );
	self sayAll(saytext);
}
saveHeadIcon()
{
	if(isdefined(self.headicon))
		self.oldheadicon = self.headicon;
	if(isdefined(self.headiconteam))
		self.oldheadiconteam = self.headiconteam;
}
restoreHeadIcon()
{
	if(isdefined(self.oldheadicon))
		self.headicon = self.oldheadicon;
	if(isdefined(self.oldheadiconteam))
		self.headiconteam = self.oldheadiconteam;
}